home *** CD-ROM | disk | FTP | other *** search
/ Adobe Graphics & Publishing SDK 1996 December / Adobe Graphics & Publishing SDK 1996 December.iso / pc / ps40sdk / examples / export / outbound / common / outboundscripting.c < prev   
Encoding:
C/C++ Source or Header  |  1996-08-26  |  2.2 KB  |  88 lines

  1. /*
  2.     File: OutboundScripting.c
  3.  
  4.     Copyright (c) 1990, Thomas Knoll.
  5.     Copyright (c) 1991-6, Adobe Systems Incorporated.
  6.     All rights reserved.
  7.  
  8.     C source file for scripting functions for Outbound export example.
  9. */
  10.  
  11. #include "Outbound.h"
  12.  
  13. /*****************************************************************************/
  14. /* Checks the parameters against scripting-returned parameters, if any, and
  15.    updates our parameters to match ones given to us by the scripting system. */
  16.  
  17. Boolean ReadScriptParams (GPtr globals)
  18. {
  19.     PIReadDescriptor            token = NULL;
  20.     DescriptorKeyID                key = NULLID;
  21.     DescriptorTypeID            type = NULLID;
  22.     DescriptorKeyIDArray        array = { keyIn, NULLID };
  23.     int32                        flags = 0;
  24.     OSErr                        stickyError = noErr;
  25.     Boolean                        returnValue = true;
  26.     
  27.     if (DescriptorAvailable())
  28.     {
  29.         token = OpenReader(array);
  30.         if (token)
  31.         {
  32.             while (PIGetKey(token, &key, &type, &flags))
  33.             {
  34.                 switch (key)
  35.                 {
  36.                     case keyIn:
  37.                         PIGetAlias(token, &(Handle)gAliasHandle);
  38.                         break;
  39.                         // ignore all other cases and classes
  40.                 }
  41.             }
  42.  
  43.             stickyError = CloseReader(&token); // we're done, dispose.
  44.             
  45.             if (stickyError)
  46.             {
  47.                 if (stickyError == errMissingParameter)
  48.                     ;
  49.                     /* (descriptorKeyIDArray != NULL) Missing a parameter.
  50.                        Walk IDarray for which one. */
  51.                 else
  52.                     gResult = stickyError; // real error occurred
  53.             }
  54.         }
  55.         gQueryForParameters = returnValue = PlayDialog();
  56.         /* return TRUE if want to show our Dialog */
  57.     }
  58.     return returnValue;
  59. }
  60.  
  61. /*****************************************************************************/
  62. /* Writes our parameters to the scripting system. */
  63.  
  64. OSErr WriteScriptParams (GPtr globals)
  65. {
  66.     PIWriteDescriptor            token = nil;
  67.     OSErr                        gotErr = noErr;
  68.                 
  69.     if (DescriptorAvailable())
  70.     {
  71.         token = OpenWriter();
  72.         if (token)
  73.         {                    
  74.             PIPutAlias(token, keyIn, (Handle)gAliasHandle);
  75.             gotErr = CloseWriter(&token); // closes and sets to dialogOptional
  76.  
  77.             /* dispose the handle we created.  Since it's different on
  78.                Mac and Windows, we'll put the destroy routine in UIMac or UIWin. */                    
  79.             
  80.             DestroyAliasHandle (globals);
  81.             /* done.  Now pass handle on to Photoshop */
  82.         }
  83.     }
  84.     return gotErr;
  85. }
  86.  
  87. /*****************************************************************************/
  88.